package com.csap.framework.apidoc.example;

import com.csap.framework.annotation.ResponseAdvice;
import com.csap.framework.annotation.apidoc.Api;
import com.csap.framework.annotation.apidoc.ApiOperation;
import com.csap.framework.annotation.apidoc.ApiProperty;
import com.csap.framework.annotation.apidoc.ApiPropertys;
import com.csap.framework.apidoc.example.model.ExampleModel;
import com.csap.framework.properties.apidoc.ParamType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @author yangchengfu
 * @description
 * @dataTime 2021年-01月-26日 14:43:00
 **/
@Api("示例")
@RestController
@RequestMapping("example")
@ResponseAdvice
public class ExampleController {

    @ApiOperation(value = "验证", paramType = ParamType.BODY)
    @PostMapping("validate")
    public ExampleModel validate(@RequestBody ExampleModel exampleModel) {
        return exampleModel;
    }
//
//    @ApiOperation(value = "验证单参数", paramType = ParamType.QUERY)
//    @ApiPropertys({
//            @ApiProperty(value = "姓名", name = "name"),
//            @ApiProperty(value = "年龄", name = "age", required = true)
//    })
//    @GetMapping("validateParam")
//    public ExampleModel validateParam(@NotNull(message = "姓名不能为空") String name,
//                                      @NotNull(message = "年龄不能为空") Integer age) {
//        return null;
//    }
//
//    @ApiOperation(value = "验证bodyList数据", paramType = ParamType.BODY)
//    @ApiPropertys({
//            @ApiProperty(value = "姓名", name = "name", required = true),
//    })
//    @PostMapping("validateBodyList")
//    public List<String> validateBodyList(@NotEmpty(message = "姓名不能为空") @RequestBody List<String> name) {
//        return name;
//    }
}
